{% load i18n %}

{% if app_list %}
    <div class="h-0 flex-grow overflow-auto" data-simplebar>
        {% for app in app_list %}
            <div class="app-{{ app.app_label }} module{% if app.app_url in request.path %} current-app{% endif %}">
                <ol class="px-6">
                    {% if app.models and not app.hidden %}
                        <li>
                            {% if app.name %}
                                <h2>
                                    <a href="{{ app.app_url }}" class="block font-semibold mb-2 mt-4 text-font-important-light text-sm truncate dark:text-font-important-dark" title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">
                                        {{ app.name }}
                                    </a>
                                </h2>
                            {% endif %}

                            <ol>
                                {% for model in app.models %}
                                    {% if not model.hidden %}
                                        <li class="model-{{ model.object_name|lower }}{% if model.admin_url in request.path|urlencode %} current-model{% endif %}">
                                            {% if model.header %}
                                                <h3 class="font-medium my-3 text-gray-900 text-sm dark:text-gray-200">
                                                    {{ model.header }}
                                                </h3>
                                            {% endif %}

                                            {% if model.admin_url %}
                                                <a href="{{ model.admin_url }}" id="link-{{ app.app_label }}-{{ model.object_name|lower }}"
                                                   class="block -mx-3 px-3 py-3 rounded-md truncate hover:text-primary-600 dark:hover:text-primary-500 {% if model.admin_url in request.path|urlencode %}bg-gray-100 font-semibold text-primary-600 dark:bg-white/[.06] dark:text-primary-500{% endif %}">
                                                    {{ model.name }}
                                                </a>
                                            {% else %}
                                                {{ model.name }}
                                            {% endif %}
                                        </li>
                                    {% endif %}
                                {% endfor %}
                            </ol>
                        </li>
                    {% endif %}
                </ol>
            </div>
        {% endfor %}
    </div>
{% else %}
    <p>{% translate 'You don’t have permission to view or edit anything.' %}</p>
{% endif %}
